<template>
  <div>
    <nav-bar></nav-bar>
    <div class="collection"><h3>我的收藏</h3></div>

    <div class="goodList">
      <div
        class="item"
        v-for="item in showList"
        :key="item.id"
        @click="goGoods(item.id)"
      >
        <img :src="item.list_pic_url" alt="" />
        <p class="name">{{ item.name }}</p>
        <p class="price">￥{{ item.retail_price }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import Navbar from "../../../components/Navbar";
import { collection } from "@/api/my/collection/index.js";
export default {
  props: {},
  data() {
    return {
      showList: [],
    };
  },
  computed: {},
  created() {
    this.init();
  },
  mounted() {},
  watch: {},
  methods: {
    init() {
      collection({
        openId: localStorage.getItem("openId"),
      }).then((res) => {
        console.log(res);
        this.showList = res.collectGoodsList;
      });
    },
  },
  components: {
    "nav-bar": Navbar,
  },
};
</script>

<style lang="scss" scoped>
h3 {
  margin: 0;
}
.collection {
  background-color: #fff;
  width: 100%;
}
.goodList {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  .item {
    width: 186px;
    margin-bottom: 2px;
    text-align: center;
    background: #fff;
    padding: 7.5px 0;
    img {
      display: block;
      width: 151px;
      height: 151px;
      margin: 0 auto;
    }
    .name {
      margin: 7px 0 11px 0;
      text-align: center;
      padding: 0 10px;
      font-size: 12px;
    }
    .price {
      text-align: center;
      font-size: 15px;
      color: #b4282d;
    }
  }
}
</style>
